﻿@model Tuple<List<deviceManage.Models.BuyContract>, deviceManage.Models.Project>
@{
    ViewData["Title"] = "项目管理";
}
<style>

    .layui-layout-body {
        overflow: auto;
    }
    .layui-form-label.value {
        width: auto;
        padding-left: 0px;
    }
</style>
 
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <form class="layui-form" action="doCreate" lay-filter="saveForm">
                        <input type="hidden" name="id" id="id" value="@Model.Item2.Id" />

                        <div class="layui-card">
                            <div class="layui-card-header">项目基本信息</div>
                            <div class="layui-card-body" style="padding: 15px;">



                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">项目名称：</label>
                                        <label class="layui-form-label value">@Model.Item2.Name</label>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">建设单位：</label>
                                        <label class="layui-form-label value">@Model.Item2.DevelopUnit</label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">使用单位：</label>
                                        <label class="layui-form-label value">@Model.Item2.UseUnit</label>
                                    </div>


                                    <div class="layui-inline">
                                        <label class="layui-form-label">绑定合同：</label>
                                        <label class="layui-form-label value">

                                            @foreach (var x in Model.Item1)
                                            {
                                                @if (x.Id.Equals(Model.Item2.ContractId))
                                                {
                                                    @x.Title
                                                }
                                            }

                                        </label>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">开始时间：</label>

                                        <label class="layui-form-label value">
                                            @if (Model.Item2.StartTime != null)
                                            {
                                                @Model.Item2.StartTime.ToString().Substring(0, 10);
                                            }
                                        </label>

                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">完成时间：</label>

                                        <label class="layui-form-label value">
                                            @if (Model.Item2.FinishDate != null)
                                            {
                                                @Model.Item2.FinishDate.ToString().Substring(0, 10);
                                            }
                                        </label>

                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width:120px;">投资金额(元）：</label>
                                        <label class="layui-form-label value">
                                            @Model.Item2.Amount
                                        </label>
                                    </div>


                                    <div class="layui-block">
                                        <label class="layui-form-label">参与人：</label>
                                        <label class="layui-form-label value">@Model.Item2.Participate</label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-tab layui-tab-card" style="background-color:white;">
                            <ul class="layui-tab-title">
                                <li class="layui-this">立项文件</li>
                                <li>招标文件</li>
                                <li>项目建设文件</li>
                                <li>项目验收文件</li>
                                <li>项目培训文件</li>
                                <li>对应设备文件</li>
                                <li>其他文件</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">

                                    <table class="layui-table layuiadmin-page-table" id="table_lx" lay-skin="line"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-tab-item layui-show">

                                        <table class="layui-table layuiadmin-page-table" id="table_zb" lay-skin="line"></table>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-tab-item layui-show">

                                        <table class="layui-table layuiadmin-page-table" id="table_js" lay-skin="line"></table>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-tab-item layui-show">
                                       
                                        <table class="layui-table layuiadmin-page-table" id="table_ys" lay-skin="line"></table>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-tab-item layui-show">

                                        <table class="layui-table layuiadmin-page-table" id="table_px" lay-skin="line"></table>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-tab-item layui-show">

                                        <table class="layui-table layuiadmin-page-table" id="table_sb" lay-skin="line"></table>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-tab-item layui-show">

                                        <table class="layui-table layuiadmin-page-table" id="table_qt" lay-skin="line"></table>
                                    </div>
                                </div>
                            </div>
                        </div>

                        

                       

                    </form>
                </div>                
            </div>
        </div>
   

<script>


    var $ = layui.$
        , admin = layui.admin
        , element = layui.element
        , layer = layui.layer
        , laydate = layui.laydate
        , form = layui.form
        , table = layui.table;
        upload = layui.upload;


    form.render(null, 'saveForm');

    //设置菜单
    $('#m_project_go').addClass("layui-this");
    $('#m_project').addClass("layui-nav-itemed");


    var insStart = laydate.render({
        elem: '#StartDate'        
    });
   

    /* 自定义验证规则 */
    form.verify({
        money: [/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/, '金额格式不正确']
    });



    //加载table
    function renderTable(tableId,category) {
         var tableObj = table.render({
             elem: tableId
            , url: '/doc/getAllByObjectId?&category='+category+'&id=@Model.Item2.Id' //其他文件
            , cols: [[
                { field: 'name', title: '文件名称', width: 400, templet: '<div><a class="fileLink" href="/doc/download?id={{d.id}}">{{ d.name}}</a></div>' },                  
                ]]
        , skin: 'line'
        });
        return tableObj;
    }

    var table_lx  = renderTable("#table_lx", 3); //立项    
    var table_zb = renderTable("#table_zb", 4);//招标
    var table_js = renderTable('#table_js', 5); //建设         
    var table_ys = renderTable("#table_ys", 6);//验收
    var table_px = renderTable("#table_px", 7);//培训
    var table_sb = renderTable("#table_sb", 8);//设备文件    
    var table_qt = renderTable("#table_qt", 9);//其他文件
 
     

       

    /* 监听提交 */
    form.on('submit(save)', function (data) {
        //开始保存合同信息
        $.post("/project/save", data.field,
            function (e) {
               layer.msg(e.msg);
                if (e.code == 1) { //保存成功
                  window.parent.tableObj.reload();
                  window.parent.layer.closeAll()
              }
            });
            return false;
    });


    var id = $('#id').val();
    
 

 

</script>
